#pragma once
#include <iostream>
#include <Windows.h>
#include <ctime>
#include <conio.h>
#define VK_RETURN 0x0D
#define VK_Q 0x57
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;

class KeyInput
{
public:
	static bool Enter()
	{
		bool onPress = !KEYDOWN_ENTER && KEY_DOWN(VK_RETURN);
		KEYDOWN_ENTER = KEY_DOWN(VK_RETURN);
		return onPress;
	}
	static bool Exit()
	{
		return KEY_DOWN(VK_Q);
	}
private:
	static bool KEYDOWN_ENTER;
	BYTE scan_code(DWORD pKey)
	{
		const DWORD result = MapVirtualKey(pKey, MAPVK_VK_TO_VSC);
		return static_cast<BYTE>(result);
	}
	void press_key(DWORD pKey)
	{
		keybd_event(static_cast<BYTE>(pKey), scan_code(pKey), 0, 0);
	}
	void release_key(DWORD pKey)
	{
		keybd_event(static_cast<BYTE>(pKey), scan_code(pKey), KEYEVENTF_KEYUP, 0);
	}
};
bool KeyInput::KEYDOWN_ENTER = false;
